<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2018/12/15
 * Time: 15:25
 */

namespace service\k3;


class K3ReaderFactory
{
    private static $typeOrderMapping = [
        'work' => '\\service\\k3\\order\\CommonOrder',
        'ww' => '\\service\\k3\\order\\ForeignOrder',
        'qout' => '\\service\\k3\\order\\OtherOrder',
        'chg' => '\\service\\k3\\order\\ChangeOrder',
        'poord'=>'\\service\\k3\\purchase\\CommonPurchase',
        'qin'=>'\\service\\k3\\purchase\\QinPurchase',
        'supplier' => '\\service\\k3\\util\\SupplierReader',
        'materiel' => '\\service\\k3\\util\\MaterielReader',
        'inventory' => '\\service\\k3\\util\\InventoryReader',
    ];

    /**
     * 查询k3出库单数据
     *
     * @param string $type 出库单类型
     * @param string $condition 查询条件ww类型需要传递两个参数
     * @return mixed
     */
    public static function read($type = '', $condition = '')
    {
        $type = strtolower($type);
        if (in_array($type, array_keys(self::$typeOrderMapping))) {
            $class = self::$typeOrderMapping[$type];
            $handler = new $class;
            return $handler->read($condition);
        }
        return null;
    }
}